<?php
class Read_circle extends MY_Controller{
	//获取读书圈精选习惯
	function habit_list(){
		$this->load->model("Read_circles");
		$data = $this->user_post_data;
		$subject_id = 0;
		if(!empty($data['subject_id'])){
			$subject_id = $data['subject_id'];
		}
		$read_habits = get_field_by_where("read_habits", "habit_ids", "subject_id='{$subject_id}'");
		if(empty($read_habits['habit_ids'])){
			echo json_encode(array("code" => 0));
		}else{
			$habit_list = $this->Read_circles->get_habit_data($read_habits['habit_ids']);
			echo json_encode(array("code" => 1, "data" => $habit_list));
		}
	}

	//获取读书圈精选图书
	function book_list(){
		$this->load->model("Read_circles");
		$data = $this->user_post_data;
		$subject_id = 0;
		if(!empty($data['subject_id'])){
			$subject_id = $data['subject_id'];
		}
		$read_books = get_field_by_where("read_books", "book_ids", "subject_id='{$subject_id}'");
		if(empty($read_books['book_ids'])){
			echo json_encode(array("code" => 0));
		}else{
			$book_list = $this->Read_circles->get_book_data($read_books['book_ids']);
			echo json_encode(array("code" => 1, "data" => $book_list));
		}
	}

	//获取读书圈精选阅读
	function article_list(){
		$this->load->model("Read_circles");
		$data = $this->user_post_data;
		$subject_id = 0;
		if(!empty($data['subject_id'])){
			$subject_id = $data['subject_id'];
		}
		$read_articles = get_field_by_where("read_articles", "article_ids", "subject_id='{$subject_id}'");
		if(empty($read_articles['article_ids'])){
			echo json_encode(array("code" => 0));
		}else{
			$article_list = $this->Read_circles->get_article_data($read_articles['article_ids']);
			echo json_encode(array("code" => 1, "data" => $article_list));
		}
	}

	//获取基于读书圈精选习惯下的用户动态数据
	function user_dynamic_list(){
		$this->load->model("Read_circles");
		$data = $this->user_post_data;
		$subject_id = 0;
		if(!empty($data['subject_id'])){
			$subject_id = $data['subject_id'];
		}
	}
}